#!/bin/bash

# The read command will assign all data entered at the prompt to a single
# variable, or you can specify multiple variables. Each data value entered is
# assigned to the next variable in the list. If the list of variables runs out
# before the data does, the remaining data is assigned to the last variable.
read -p "Enter your name: " first last
echo "Checking data for $last, $first..."

# timeout
if read -t 5 -p "Please enter your name: " name; then
    echo "Hello $name, welcome to my script."
else
    echo
    echo "Sorry, too slow!"
fi

# count
read -n1 -p "Do you want to continue [Y/N]? " answer
case $answer in
    Y | y) echo
        echo "fine, continue on..." ;;
    N | n) echo
        echo "OK, goodbye"
        exit;;
esac
echo "This is the end of the script"

# silent
read -s -p "Enter your password: " pass
echo
echo "Is your password really $pass? "

# read file
count=1
test=/etc/issue
cat $test | while read line; do
    echo "Line $count: $line"
    count=$[ $count + 1]
done
echo "Finished processing the file"

